package cn.hsp.twocolorball;

import java.util.Random;
/**
 * 厦门大学计算机专业 | 前华为工程师
 * 专注《零基础学编程系列》https://cxyxy.blog.csdn.net/article/details/121134634
 * 包含：Java | 安卓 | 前端 | Flutter | iOS | 小程序 | 鸿蒙
 * 公众号：蓝不蓝编程
 */
public class BallNumUtil {
    private final Random random = new Random();
    private final int RED_BALL_MAX_NUM = 33;
    private final int BLUE_BALL_MAX_NUM = 16;

    public String getRedBallNum() {
        int num = getRandom(RED_BALL_MAX_NUM);
        return formatNum(num);
    }

    public String getBlueBallNum() {
        int num = getRandom(BLUE_BALL_MAX_NUM);
        return formatNum(num);
    }

    private String formatNum(int num) {
        if (num < 10) {
            return "0" + num;
        } else {
            return "" + num;
        }
    }

    private int getRandom(int maxValue) {
        int randomValue = Math.abs(random.nextInt());
        return randomValue % maxValue + 1;
    }
}
